home *** CD-ROM | disk | FTP | other *** search
/ Nebula 1 / Nebula One.iso / Utilities / Converters / Convert_MacPaint / Source / shared.subproj / RCS / Reply.m,v < prev    next >
Text File  |  1995-06-12  |  7KB  |  251 lines

  1. head     1.2;
  2. branch   ;
  3. access   ;
  4. symbols  ;
  5. locks    ; strict;
  6. comment  @@;
  7.  
  8.  
  9. 1.2
  10. date     92.03.29.12.14.23;  author death;  state Exp;
  11. branches ;
  12. next     1.1;
  13.  
  14. 1.1
  15. date     92.03.22.15.47.49;  author death;  state Exp;
  16. branches ;
  17. next     ;
  18.  
  19.  
  20. desc
  21. @This is the definition of the reply object.  Really, i'd have to say it's an
  22. experimental object.  I dunno how much I'm going to like it.  But I forsee some
  23. revision ahead if I end up making serious use of it.
  24. @
  25.  
  26.  
  27. 1.2
  28. log
  29. @ turns out that 2.0 wants init calls to be in the object, not the class.
  30. Modified accordingly.
  31. @
  32. text
  33. @/*
  34. ====================================================================
  35. This is the implementation file for the reply class.  Full documentation for this class can be found in the Reply.rtf file.  I will not duplicate all that fine information here.
  36.     This is $Revision: 1.1 $ of this file
  37.     It was last modified by $Author: death $ on $Date: 92/03/22 15:47:49 $
  38. Note that this file was created while using the New Century Schoolbook Roman typeface.  You may find that some things line up strangely if you don't use that family.
  39. $Log:    Reply.m,v $
  40. Revision 1.1  92/03/22  15:47:49  death
  41. Initial revision
  42.  
  43.  
  44. ====================================================================
  45. */
  46.  
  47. //
  48. //    Import our own definition
  49. //
  50. #import "Reply.h"
  51. #import <strings.h>
  52. #import <stdlib.h>
  53.  
  54.  
  55. @@implementation Reply
  56.  
  57. /**********************************************************************************
  58.     This is the main initalization method.  It initalizes the errorinfo part of itself, and then
  59.     initalizes the data parts..
  60. **********************************************************************************/
  61. - (id) initReplyWithCode: (long int) code Text: (Cstring) text Kind: (long int) kind
  62.     Data: (void*) dataVal Type: (int) theType
  63. {
  64.     [super  initErrorWithCode: code Text:  text Kind: kind];
  65.     dataType = theType;
  66.     theData = 0L;
  67.     theData = (unsigned long int) dataVal;
  68.     return self;
  69. }
  70.  
  71.  
  72. /**********************************************************************************
  73.     This just calls initReplyWithCode:Text:Kind:Data:Type: with its given parameters.
  74. **********************************************************************************/
  75. - (id) initReplyWithCode: (long int) code Text: (Cstring) text Data: (void*) dataVal Type: (int) theType
  76. {
  77.     return [self initReplyWithCode: code
  78.         Text: text
  79.         Kind: ERRKIND_GENERAL
  80.         Data: dataVal
  81.         Type: theType];
  82. }
  83.  
  84.  
  85. /**********************************************************************************
  86.     This just calls initReplyWithCode:Text:Kind:Data:Type: with its given parameters.
  87. **********************************************************************************/
  88. - (id)  initReplyWithCode: (long int) code Text: (Cstring) text Data: (void*) dataVal
  89. {
  90.     return [self initReplyWithCode: code
  91.         Text: text
  92.         Kind: ERRKIND_GENERAL
  93.         Data: dataVal
  94.         Type: TYPE_GENERAL];
  95. }
  96.  
  97.  
  98.  
  99. /*********************************************************************************
  100.     In this method, we merely free the object.  This action involves getting rid of the text string if it is there, and then asking our superclass to free. 
  101. **********************************************************************************/
  102. - free
  103. {
  104.     if (dataType == TYPE_CSTRING)
  105.         free((char*) theData);
  106.     return [super    free];
  107. }
  108.  
  109.  
  110. /*********************************************************************************
  111.     Returns data as if it were a byte.
  112. **********************************************************************************/
  113. - (byte) getByte
  114. {
  115.     return (byte) theData;
  116. }
  117.  
  118.  
  119. /*********************************************************************************
  120.     Returns data as if it were a character.
  121. **********************************************************************************/
  122. - (char) getChar
  123. {
  124.     return (char) theData;
  125. }
  126.  
  127.  
  128. /*********************************************************************************
  129. Make a copy of the string and return it to the caller.  If this string is null, this all works transparently anyay.
  130. **********************************************************************************/
  131. - (Cstring) getCstring
  132. {
  133.     Cstring    tempString;
  134.     
  135.     //    Allocate as much space as the length of the string +1
  136.     //
  137.     tempString = (Cstring) malloc (strlen((char*) theData) + 1);
  138.     
  139.     //    Make a copy of the error text into the new location
  140.     //
  141.     if (tempString != NULL)
  142.         (void) strcpy(tempString, (char*) theData);    // we don't care about getting a pointer back
  143.     
  144.     //    Finally, return a pointer to this new string.
  145.     //
  146.     return tempString;
  147. }
  148.  
  149.  
  150. /*********************************************************************************
  151.     Returns data as if it were a genral data type.
  152. **********************************************************************************/
  153. - (void*) getGeneral
  154. {
  155.     return (void*) theData;
  156. }
  157.  
  158.  
  159. /*********************************************************************************
  160.     Returns data as if it were a genral data type.
  161. **********************************************************************************/
  162. - (short) getShort
  163. {
  164.     return (short) theData;
  165. }
  166.  
  167.  
  168. /*********************************************************************************
  169.     Returns data as if it were a int data type.
  170. **********************************************************************************/
  171. - (int) getInt
  172. {
  173.     return (int) theData;
  174. }
  175.  
  176.  
  177. /*********************************************************************************
  178.     Returns data as if it were a long data type.
  179. **********************************************************************************/
  180. - (long) getLong
  181. {
  182.     return (long) theData;
  183. }
  184.  
  185.  
  186. /*********************************************************************************
  187.     Returns data as if it were an object.
  188. **********************************************************************************/
  189. - (id) getObject
  190. {
  191.     return (id) theData;
  192. }
  193.  
  194.  
  195. /*********************************************************************************
  196.     Returns data as if it were a genral data type.
  197. **********************************************************************************/
  198. - (unsigned short) getUnsignedShort
  199. {
  200.     return (unsigned short) theData;
  201. }
  202.  
  203.  
  204. /*********************************************************************************
  205.     Returns data as if it were a int data type.
  206. **********************************************************************************/
  207. - (unsigned int) getUnsignedInt
  208. {
  209.     return (unsigned int) theData;
  210. }
  211.  
  212.  
  213. /*********************************************************************************
  214.     Returns data as if it were a long data type.
  215. **********************************************************************************/
  216. - (unsigned long) getUnsignedLong
  217. {
  218.     return (unsigned long) theData;
  219. }
  220.  
  221. @@end
  222. @
  223.  
  224.  
  225. 1.1
  226. log
  227. @Initial revision
  228. @
  229. text
  230. @d4 2
  231. a5 2
  232.     This is $Revision: 1.2 $ of this file
  233.     It was last modified by $Author: death $ on $Date: 92/02/09 18:40:15 $
  234. d7 3
  235. a9 1
  236. $Log:    ErrorInfo.m,v $
  237. d11 1
  238. d29 1
  239. a29 1
  240. + (id) initReplyWithCode: (long int) code Text: (Cstring) text Kind: (long int) kind
  241. d43 1
  242. a43 1
  243. + (id) initReplyWithCode: (long int) code Text: (Cstring) text Data: (void*) dataVal Type: (int) theType
  244. d56 1
  245. a56 1
  246. + (id)  initReplyWithCode: (long int) code Text: (Cstring) text Data: (void*) dataVal
  247. d70 1
  248. a70 1
  249. + free
  250. @
  251.